package com.wulis.common.utils;

import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;

import com.wulis.config.security.AuthUserDetails;

/**
 * @author WuliBao
 * @date 2020-04-17
 */
public class AuthUserUtil {
    public static AuthUserDetails getDetails() {
        SecurityContext securityContext = SecurityContextHolder.getContext();
        if (securityContext == null) {
            return new AuthUserDetails();
        }
        else {
            return (AuthUserDetails)securityContext.getAuthentication().getPrincipal();
        }
    }
}
